/*
 * @Author: viivLgr 
 * @Date: 2018-05-03 14:37:35 
 * @Last Modified by: viivLgr
 * @Last Modified time: 2018-06-07 18:07:31
 */
import React            from 'react';
import ReactDOM         from 'react-dom';
import { BrowserRouter as Router, Route, Redirect, Switch, Link } from 'react-router-dom'

// 頁面
import Layout           from 'component/layout/index.jsx';
import Home             from 'page/home/index.jsx';
import Login            from 'page/login/index.jsx';
import ErrorPage        from 'page/error/index.jsx';
import UserList         from 'page/user/index.jsx';
import ProductRouter    from 'page/product/router.jsx';
import OrderList        from './page/order/index.jsx';
import OrderDetail      from './page/order/detail.jsx';

class App extends React.Component {
  constructor(props) {
    super(props);
  }
  render() {
    let LayoutRouter = (
      <Layout>
        <Switch>
          <Route exact path="/" component={Home} />
          <Route path="/product" component={ProductRouter} />
          <Route path="/product-category" component={ProductRouter} />
          <Route path="/user" component={UserList} />
          <Route path="/order/index" component={OrderList} />
          <Route path="/order/detail/:id" component={OrderDetail} />
          <Redirect exact from="/user" to="/user/index" />
          <Redirect exact from="/order" to="/order/index" />
          <Route component={ErrorPage} />
        </Switch>
      </Layout>
    )
    return (
      <div>
        <Router>
          <Switch>
            <Route path="/login" component={Login} />
            <Route path="/" render={props => LayoutRouter} />
          </Switch>
        </Router>
      </div>
    );
  }
}

ReactDOM.render(
  <App />,
  document.getElementById('app')
);